package 
{
	import Common.ModInterfaces.Net.IMessage;
	import Common.ModInterfaces.Net.MessageEvent;
	import Common.ModInterfaces.Net.SocketManageEvent;
	import Common.VO.Net.JMessage;
	import flash.display.Sprite;
	import flash.events.Event;
	import NetModule.LogicLayer.SocketManager;
	
	/**
	 * ...
	 * @author 	 *	Copyright (c) 2012 IGG研发中心
	 *      All rights reserved
	 *
	 *		@创 建 时 间:  
	 *		@说       明: 网络模块
	 *
	 *		@作       者: cgy
	 *		@版       本: 1.0.0
	 *     @概       述: 创建
	 */
	public class Main extends Sprite 
	{
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			trace("test");
			//SocketManager.singleton.connect("127.0.0.1", 9450);
			SocketManager.singleton.addEventListener(SocketManageEvent.onHandlerConnected, onHandlerConnected);
			SocketManager.singleton.addEventListener(MessageEvent.Net, onHandlerNet);
		}
		
		private function onHandlerNet(e:MessageEvent):void 
		{
			var m:IMessage = e.message;
		}
		
		private function onHandlerConnected(e:SocketManageEvent):void 
		{
			var msg:JMessage = new JMessage(1);
			msg.json = "{a:5}";
			SocketManager.singleton.sendData(msg);
		}
		

		
	}
	
}